package com.qf.aspect;

import org.aspectj.lang.ProceedingJoinPoint;
import org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint;

/**
 * @ClassName MyAspect
 * @Description TODO
 * @Author 86181
 * @Date 2022/8/31 23:13
 * @Version 1.0
 **/
public class MyAspect {
    public void before(){
        System.out.println("目标方法执行前执行");
    }
    public void afterReturning(){
        System.out.println("目标执行后执行");
    }
    public void around(ProceedingJoinPoint proceedingJoinPoint){
        System.out.println("环绕之前");
        try {
            proceedingJoinPoint.proceed();
        } catch (Throwable throwable) {
            throwable.printStackTrace();
        }
        System.out.println("环绕之后");
    }

    //异常通知
    public void throwReturning(Throwable throwable){
        System.out.println("执行异常通知"+throwable.getMessage());

    }
    //执行最终通知
    public void after(){
        System.out.println("执行最终通知");
    }
}
